//
//  SRDeviceInfo+description.m
//  CareRing
//
//  Created by  on 2022/7/26.
//

#import "CADeviceInfo+description.h"
#import "ConfigModel.h"

@implementation CADeviceInfo (description)

+(NSString *)colorDesc:(CA_DEV_COLOR)color;
{
    switch (color) {
        case CA_DEV_COLOR_SILVER:
        {
            return _L2(L_DEV_COLOR_SILVER);
        }
            break;
        case CA_DEV_COLOR_DARK:
        {
            return _L2(L_DEV_COLOR_DARK);
            
        }
            break;
        case     CA_DEV_COLOR_GOLD:
        {
            return _L2(L_DEV_COLOR_GOLD);
            
        }
            break;
        case CA_DEV_COLOR_ROSE_GOLD:
        {
            return _L2(L_DEV_COLOR_ROSE_GOLD);
        }
            break;
        case CA_DEV_COLOR_Silver_Gold_Mixed: //金/银混色(Gold and silver mixed)
        {
            return _L2(L_DEV_COLOR_Silver_Gold_Mixed);
        }
            break;
        case   CA_DEV_COLOR_Gold_Silver_Mixed : //紫/银混色(Purple and silver mixed)
        {
            return _L2(L_DEV_COLOR_Gold_Silver_Mixed);
            
        }
            break;
        case   CA_DEV_COLOR_Champagne_Gold_Silver_Mixed : //玫瑰金/银混色(Rose gold and silver mixed)
        {
            return _L2(L_DEV_COLOR_Champagne_Gold_Silver_Mixed);
            
        }
            break;
        case   CA_DEV_COLOR_Rose_Gold_Silver_Mixed://玫瑰金/银混色(Rose Gold/Silver Mixed)
        {
            return _L2(L_DEV_COLOR_Rose_Gold_Silver_Mixed);
        }
            break;
        case    CA_DEV_COLOR_Brushed_Silver ://拉丝银(Brushed Silver )
        {
            return _L2(L_DEV_COLOR_Brushed_Silver);
        }
            break;
        case    CA_DEV_COLOR_Stealth ://黑色磨砂(Stealth)
        {
            return _L2(L_DEV_COLOR_Stealth);
        }
            break;
        case CA_DEV_COLOR_Gun_Color:
        {
            return _L2(L_DEV_COLOR_Gun_Color);
        }
            break;
        default:
//            DebugNSLog(@"未知颜色 code: %d", color);
            return [NSString stringWithFormat:@"Unknow Color Code:%lu",color];
            break;
    }
    return @"";
    
}


+(NSString *)sizeDesc:(int)size
{
    return [NSString stringWithFormat:@"%@%d", _L2(L_DEV_SIZE_US), size];
}

+(NSString *)descryOfErrorReason:(CA_CMD_EXECTE_ERROR_REASON)reason
{
    NSString *desc = @"";
    switch (reason) {
        case     CA_REASON_1:  // 设备自动测量中
        {
            desc = _L2(L_TXT_DEV_IS_MEASURING);
        }
            break;
        case     CA_REASON_2:// 设备在运动模式测量中
        {
            desc = _L2(L_TXT_DEV_IS_EXERCING);
        }
            break;
        case     CA_REASON_3: // 设备app测量中
        {
            desc = _L2(L_TXT_DEV_IS_MEASURING);
        }
            break;
        case     CA_REASON_4: // 参数错误
        {
            desc = _L2(L_TXT_CMD_ARGU_ERROR);
        }
            break;
        case     CA_REASON_5:
        {
            desc = _L2(L_TXT_CMD_STATUS_NOT_SUPP);
        }
            break;
        default:
            break;
    }
    
    return desc;
}


+(NSString *)stringFromUserInfo:(NSUInteger)gender
                Age:(NSUInteger)ageYear
              Height:(NSUInteger)height
                     Weight:(NSUInteger)weight
{
//    DebugNSLog(@"sr28用户信息 性别 %lu,年龄 %lu, 身高 %lu mm, 体重 %lu kg", (unsigned long)gender,
//               (unsigned long)ageYear, (unsigned long)height, (unsigned long)weight);
    NSString *genderStr = gender == 0 ? _L2(L_RI_MALE):_L2(L_RI_FEMALE) ;
    
    return [NSString stringWithFormat:@"%@ %@:%@, %@:%lu, %@:%lu mm, %@:%lu kg", _L2(L_USR_INFO),
            _L2(L_UD_SEX),genderStr,
            _L2(L_UD_AGE),ageYear,
            _L2(L_UD_HEIGHT),height,
            _L2(L_UD_WEIGHT),weight
    ];
}

-(NSString *)wholeInfomationDescText {
   
    
    NSMutableString *infoString = [NSMutableString new];
    // color
    [infoString appendFormat:@"%@\n", [CADeviceInfo colorDesc:self.color]];
    // size
    [infoString appendFormat:@"%@\n", [CADeviceInfo sizeDesc:(int)self.size]];
    [infoString appendFormat:@"Gen:%lu\n",  (unsigned long)self.generation];
    [infoString appendFormat:@"%@:%@\n", _L2(L_TX_MAC_ADDR), self.bleMacAddress];
    [infoString appendFormat:@"Firmware Version:%@\n", self.softWareVersion];

    [infoString appendFormat:@"OEM Auth switch:%@\n", self.needOemAuth ? @"On": @"Off"];

    [infoString appendFormat:@"%@:%@\n", _L2(L_TX_CHARGE_MODE), self.stringOfChargeMode ];

    [infoString appendFormat:@"%@:%@\n", _L2(L_SUPP_WORKOUT), self.supportSportmode ? _L2(L_YES):_L2(L_NO) ];
    [infoString appendFormat:@"%@:%@\n", _L2(L_SUPP_ECG), self.supportEcg ? _L2(L_YES):_L2(L_NO) ];

    [infoString appendFormat:@"%@:%@\n", _L2(L_ECG_ALGO), self.stringOfEcgAlgoType];

    [infoString appendFormat:@"%@:%@\n", _L2(L_PPG_ALGO), self.isSelfDevelopedAlgorithm ? _L2(L_ALGO_TYPE_OLD) : _L2(L_ALGO_TYPE_NEW)];



    
    
    return infoString;
    
}

-(NSString *)stringOfChargeMode
{
    NSString *str = @"";
  
    if (self.chargeType == 0) {
        str = _L2(L_CHARGE_MA);
    }
    if (self.chargeType == 1) {
        str = _L2(L_CHARGE_WILESS);
    }
    if (self.chargeType == 2) {
        str = _L2(L_CHARGE_NFC);
    }
    return str;
}

// ecgCalcType
-(NSString *)stringOfEcgAlgoType
{
    NSString *str = @"";
  
    if (self.ecgCalcType == CA_ECG_CALC_ON_DEVICE) {
        str = @"Local Algorithm";
    }
    if (self.ecgCalcType == CA_ECG_CALC_ON_NET) {
        str = @"Cloud Algorithm";
    }
   
    return str;
}

@end
